<%@page contentType="text/html;charset=UTF-8" pageEncoding="UTF-8"
import="java.io.*"
%>
<%
	
	        int                 length   = 0;
	
	        ServletOutputStream op       = response.getOutputStream();
	
	        ServletContext      context  = getServletConfig().getServletContext();
	
	      
	
	        response.setContentType( "application/octet-stream" );
	        String exportCsv=(String)request.getAttribute("exportCsv");
	        if(exportCsv!=null)
	        response.setContentLength(((String)request.getAttribute("exportCsv")).getBytes().length );
	
	        response.setHeader( "Content-Disposition", "attachment; filename=\"export.csv\"" );
	
	        byte[] bbuf = new byte[1024];
			ByteArrayInputStream bi=null;
			if(exportCsv!=null)
			    bi=new ByteArrayInputStream(((String)request.getAttribute("exportCsv")).getBytes());
	        if(exportCsv==null){
	            bi=new ByteArrayInputStream("no data!".getBytes());
	        }
			while ((bi != null) && ((length = bi.read(bbuf)) != -1))
	
	        {
	
	            op.write(bbuf,0,length);
	
	        }
	
	        bi.close();
	
	        op.flush();
	
	        op.close();
	


%>